package pk.nak.client.activity;

import pk.nak.client.R;
import pk.nak.enums.AppVars;
import pk.nak.requests.AddLocationRequest;
import pk.nak.responses.AddLocationResponse;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class AddFavouritesActivity extends Activity {

	/** Called when the activity is first created. */
	private AddLocationResponse response = new AddLocationResponse(){

		@Override
		public void onSuccess(String response) {
			// TODO Auto-generated method stub
			super.onSuccess(response);
			AppVars.pdWait.dismiss();
			Toast.makeText(getApplicationContext(), "Location added", Toast.LENGTH_LONG).show();
			finish();
		}
		
	};
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.addlocation);
	    this.addHandlers();
	    // TODO Auto-generated method stub
	}
	
	private void addHandlers(){
		try{
			Button btnSave = (Button)findViewById(R.id.btnSave);
			
			if ( btnSave != null ){
				btnSave.setOnClickListener(new View.OnClickListener() {
					
					public void onClick(View v) {
						// TODO Auto-generated method stub
						String placename = "";
						EditText etName = (EditText)findViewById(R.id.etTitle);
						
						if ( etName != null ){
							placename = etName.getText().toString();
						}
						
						AddLocationRequest request = new AddLocationRequest(placename, ""+AppVars.tap_lat, ""+AppVars.tap_lng, AppVars.LogedInUserID);
						request.doRequest(response);
					}
				});
			}
		}catch(Exception ex){
			
		}
	}
}
